package net.haiyue.api.service;


import net.haiyue.api.entity.Menu;
import net.haiyue.api.entity.User;
import net.haiyue.api.repository.UserRepository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

@Service
public class MenuService {

    @Resource
    private UserRepository _userRepository;
    public List<Menu> All(String email) {
        User userByEmail = _userRepository.findUserByEmail(email);
        ArrayList<Menu> list=new ArrayList<>();
        if (userByEmail.isIs_admin()){
            Menu management=new Menu("complex","management","setting",new ArrayList<>(Arrays.asList(
                    new Menu("user_management","user_management","user"),
                    new Menu("project_management","project_management","project"),
                    new Menu("module_management","module_management","block")
            )));
            list.add(management);

            Menu report=new Menu("complex","report","coffee",new ArrayList<>(Arrays.asList(
                    new Menu("summary","summary","branches")
            )));
            list.add(report);
        }
        Menu input=new Menu("complex","input","scan",new ArrayList<Menu>(
                Arrays.asList(new Menu("daily_record","daily_record","tag"))));
        list.add(input);
        return list;
    }
}
